package com.yz.jdd.module.psd.presenter;

import com.yz.jdd.base.entity.Response_Base;
import com.yz.jdd.module.psd.view.ModifyPsdView;
import com.yz.jdd.network.MySubscriber;
import com.yz.jdd.network.NetWorkRequset;
import com.yz.jdd.network.request.Requset_usercenter;

/**
 * Created by cc on 2017/5/24.
 */

public class ModifyPsdPresenter {
    ModifyPsdView modifyPsdView;

    public ModifyPsdPresenter(ModifyPsdView modifyPsdView) {
        this.modifyPsdView = modifyPsdView;
    }
    public void modifyPsd(String psd){
        modifyPsdView.showLoading("正在加载");
        Requset_usercenter requset_pwd=new Requset_usercenter();
        requset_pwd.setPassword(psd);
        NetWorkRequset.doModifyPwd(requset_pwd, new MySubscriber() {
            @Override
            public void onSuccess(Response_Base response_baseModel) {
//                modifyPsdView.showToastDialog(response_baseModel.getMsg());
                modifyPsdView.showToastDialog(response_baseModel.getMsg());
                modifyPsdView.colseActivity("");
            }

            @Override
            public void onNeedLogin(String msg) {
                modifyPsdView.startLoginActivity();
            }

            @Override
            public void onFail(Response_Base response_baseModel) {
                modifyPsdView.showToastDialog(response_baseModel.getMsg());

            }

            @Override
            public void onCompleted() {
                super.onCompleted();
                modifyPsdView.dismissLoading();
            }
        });
    }

    public void resetPwd(String phoneNum,String psd){
        modifyPsdView.showLoading("正在加载");
        Requset_usercenter requset_pwd=new Requset_usercenter();
        requset_pwd.setPhoneNum(phoneNum);
        requset_pwd.setPassword(psd);
        NetWorkRequset.doResetPwd(requset_pwd, new MySubscriber() {
            @Override
            public void onSuccess(Response_Base response_baseModel) {
//                modifyPsdView.showToastDialog(response_baseModel.getMsg());
                modifyPsdView.showToastDialog(response_baseModel.getMsg());
                modifyPsdView.colseActivity("");
            }

            @Override
            public void onNeedLogin(String msg) {
                modifyPsdView.startLoginActivity();
            }

            @Override
            public void onFail(Response_Base response_baseModel) {
                modifyPsdView.showToastDialog(response_baseModel.getMsg());

            }

            @Override
            public void onCompleted() {
                super.onCompleted();
                modifyPsdView.dismissLoading();
            }
        });
    }
}
